{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "",
   "id": "5a99142f05b48cb2"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "#### python 中的注释\n",
    "```python\n",
    "\"\"\"\n",
    "第一个Python程序 - hello, world\n",
    "Version: 1.0\n",
    "Author: miao\n",
    "\"\"\"\n",
    "# print('hello, world')\n",
    "print(\"你好，世界！\")\n",
    "单行注释 使用 #\n",
    "多行注释 使用 \"\"\" \"\"\"\n",
    "```"
   ],
   "id": "440dd66aeb32514f"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "#### python中的数据类型\n",
    "1. int\n",
    "2. float\n",
    "3. bool\n",
    "4. str"
   ],
   "id": "a6b069076ebfca5d"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-09T12:12:49.951631Z",
     "start_time": "2025-11-09T12:12:49.947143Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from encodings.utf_7 import encode\n",
    "from past.types import basestring\n",
    "\n",
    "from requests.compat import chardet\n",
    "\n",
    "# int 整数\n",
    "#二进制\n",
    "print(0b100)\n",
    "#八进制\n",
    "print(0o100)\n",
    "#十进制\n",
    "print(100)\n",
    "#十六进制\n",
    "print(0x100)"
   ],
   "id": "54a42e64424dbf17",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "64\n",
      "100\n",
      "256\n"
     ]
    }
   ],
   "execution_count": 5
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-09T12:17:50.648988Z",
     "start_time": "2025-11-09T12:17:50.645717Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#float 浮点数\n",
    "# 如1.23456e2 科学计数法\n",
    "# 123.456\n",
    "# 正常表示方法\n",
    "print(123.456)\n",
    "# 表示乘以 10 的 2 次方 科学计数法\n",
    "print(1.23456e2)\n",
    "# 表示乘以 10 的 -2 次方 科学计数法\n",
    "print(12345.6e-2)"
   ],
   "id": "8904e51d99a13650",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "123.456\n",
      "123.456\n",
      "123.456\n"
     ]
    }
   ],
   "execution_count": 8
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": [
    "#bool 布尔类型 True False 两种值\n",
    "print(True)\n",
    "\n",
    "print(False)"
   ],
   "id": "9f8b492fb944caa9"
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": [
    "#str 单引号或着 \"\" 引号中表示的任意文本\n",
    "print('hello world')\n",
    "print(\"hello world\")\n",
    "\n",
    "#变量名不要跟 Python 的关键字重名，尽可能避开 Python 的保留字。这里的关键字是指在 Python 程序中有特殊含义的单词（如：is、if、else、for、while、True、False等），保留字主要指 Python 语言内置函数、内置模块等的名字（如：int、print、input、str、math、os等）。"
   ],
   "id": "1582b2746c307483"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "#### python 中的变量可以使用 type 函数判断类型",
   "id": "fcf4d70ca89a7a9a"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-09T12:25:11.817698Z",
     "start_time": "2025-11-09T12:25:11.814944Z"
    }
   },
   "cell_type": "code",
   "source": [
    "a =100\n",
    "b=123.45\n",
    "c='hello world'\n",
    "d=True\n",
    "\n",
    "print(type(a))\n",
    "print(type(b))\n",
    "print(type(c))\n",
    "print(type(d))"
   ],
   "id": "4e1473e13f2d853e",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n",
      "<class 'float'>\n",
      "<class 'str'>\n",
      "<class 'bool'>\n"
     ]
    }
   ],
   "execution_count": 10
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "#### python 数据类型之间的转换",
   "id": "f18d7842142d60da"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-09T12:56:49.050062Z",
     "start_time": "2025-11-09T12:56:49.043333Z"
    }
   },
   "cell_type": "code",
   "source": [
    " # int() 将一个数值或者字符串转化成整形 可以指定进制\n",
    " print(int(17.7))\n",
    " print(int('17',base=8))\n",
    " print(int(True))\n",
    " print(int(False))\n",
    "\n",
    " # float() 可以将一个字符串（可以的情况下）转换成浮点型\n",
    " print(float('17.79'))\n",
    " print(float('17'))\n",
    " # str() 可以将指定的类型转换成字符串形式 可以指定编码\n",
    " print(str(12.8898))\n",
    " print(str(True))\n",
    " print(str(tuple))\n",
    " print(str(map))\n",
    " # chr() 将整数转换换成一个字符的字符串\n",
    " print(chr(65))\n",
    " # ord() 将一个字符的字符串转化成整形\n",
    " print(ord('a'))\n",
    "\n",
    " print(bool(''))\n",
    " print(bool(\"True\"))\n",
    "\n"
   ],
   "id": "4c4e800ddfd27e1a",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "17\n",
      "15\n",
      "1\n",
      "0\n",
      "17.79\n",
      "17.0\n",
      "12.8898\n",
      "True\n",
      "<class 'tuple'>\n",
      "<class 'map'>\n",
      "A\n",
      "97\n",
      "False\n",
      "True\n"
     ]
    }
   ],
   "execution_count": 34
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
